package com.amnc.service;

import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;

import org.jboss.resteasy.client.jaxrs.ResteasyClient;
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;

import com.amnc.cattle.model.AbortionPO;
import com.amnc.cattle.model.BcsPO;
import com.amnc.cattle.model.BodyTemperaturePO;
import com.amnc.cattle.model.CalvingPO;
import com.amnc.cattle.model.ChangeGrpPO;
import com.amnc.cattle.model.DictionaryPO;
import com.amnc.cattle.model.DryPO;
import com.amnc.cattle.model.EntryAnimalsPO;
import com.amnc.cattle.model.EntryToParkingPO;
import com.amnc.cattle.model.ExitFromParkingPO;
import com.amnc.cattle.model.ExitPO;
import com.amnc.cattle.model.GeneticsDataPO;
import com.amnc.cattle.model.HeatPO;
import com.amnc.cattle.model.HeightPO;
import com.amnc.cattle.model.InsemiationPO;
import com.amnc.cattle.model.LogStallPO;
import com.amnc.cattle.model.MilkTestPO;
import com.amnc.cattle.model.MorphologicalClassificationsPO;
import com.amnc.cattle.model.NotInseminationPO;
import com.amnc.cattle.model.PDMinusPO;
import com.amnc.cattle.model.PDPlusPO;
import com.amnc.cattle.model.PDUnclearPO;
import com.amnc.cattle.model.WeightPO;


public class SendData {

	public static void send(LogStallPO logStallPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(logStallPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}


			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}
	}
	
	
	public static void sendLogStall(LogStallPO logStallPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(logStallPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}


			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}
	}
	
	
	public static void sendMilkTest(MilkTestPO milkTestPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(milkTestPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	public static void sendBodyTemperature(BodyTemperaturePO bodyTemperaturePO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(bodyTemperaturePO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}

	public static void sendDictionary(DictionaryPO dictionaryPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(dictionaryPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	public static void sendBcs(BcsPO bcsPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(bcsPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	public static void sendMorphological(MorphologicalClassificationsPO morphologicalClassificationsPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(morphologicalClassificationsPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	public static void sendHeat(HeatPO heatPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(heatPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	
	
	public static void sendEntryToParking(EntryToParkingPO entryToParkingPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(entryToParkingPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	
	
	
	public static void sendExit(ExitPO exitPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(exitPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	
	public static void sendCalving(CalvingPO calvingPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(calvingPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	public static void sendPd0(PDMinusPO pdMinusPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(pdMinusPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	public static void sendPd1(PDPlusPO pdPlusPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(pdPlusPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	public static void sendPd01(PDUnclearPO pdUnclearPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(pdUnclearPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	public static void sendExitFromParking(ExitFromParkingPO exitFromParkingPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(exitFromParkingPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	public static void sendChangeGrp(ChangeGrpPO changeGrpPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(changeGrpPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	
	public static void sendNotInsemination(NotInseminationPO notInseminationPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(notInseminationPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	
	public static void sendAbortion(AbortionPO abortionPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(abortionPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	public static void sendGenetic(GeneticsDataPO geneticsDataPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(geneticsDataPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	public static void sendEntryAnimals(EntryAnimalsPO entryAnimalsPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(entryAnimalsPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	public static void sendInsemination(InsemiationPO insemiationPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(insemiationPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	

	public static void sendDry(DryPO dryPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(dryPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	public static void sendHeight(HeightPO heightPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(heightPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	public static void sendWeight(WeightPO weightPO,String url) {
		try {
			ResteasyClient client = new ResteasyClientBuilder().build();

			ResteasyWebTarget target = client
					.target(url);
			Response response = target.request().post(
					Entity.entity(weightPO, "application/json"));

			if (response.getStatus() != 200) {
				throw new RuntimeException("Failed : HTTP error code : "
						+ response.getStatus());
			}
			System.out.println("Server response : \n");
			System.out.println(response.readEntity(String.class));
			response.close();

		} catch (Exception e) {

			e.printStackTrace();

		}

	}
	
	
	
	

}
